$(function () {
    let companyId = localStorage.getItem("companyId");
    findByCompanyId(companyId);
});

function findByCompanyId(id) {
    $.ajax({
        url: '/back/company/findByCompanyId',
        data: {id: id},
        type: 'get',
        dataType: 'json',
        success: function (data) {
            setCompanyData(data.companyModel);//需要给数据  把后台数据拿到
        }
    })
}

function setCompanyData(data) {
    $("#companyId").val(data.id);
    $("#companyName").val(data.companyName);
    $("#logo").val("");
    $("#ad").val(data.ad);
    $("#net").val(data.net);
    $("#introduce").val(data.introduce);
    $("#version").val(data.version);
}

function companyEdit() {
    let forData = new FormData();
    forData.append("companyId", $("#companyId").val());
    forData.append("companyName", $("#companyName").val());
    forData.append("logo", $("#logo")[0].files[0]);//文件取值
    forData.append("ad", $("#ad").val());
    forData.append("net", $("#net").val());
    forData.append("introduce", $("#introduce").val());
    forData.append("version", $("#version").val());
    $.ajax({
        url: '/back/company/companyEdit',
        data: forData,
        contentType: false,
        processData: false,
        type: 'post',
        dataType: 'json',
        success: function (data) {
            if (data.result === 1) {
                alert("提交成功");
                $("#right").load('/back/company/companyManage.html');
            } else {
                alert("提交失败")
            }
        }
    })
}
function cancelCompanyEdit() {
    $("#right").load('/back/company/companyManage.html');
}